import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

class MyThreadPool1{
    //创建一个存放 runnable 的阻塞队列
    public static BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>();
    //submit 提交 runnable
    public void submit(Runnable runnable) throws InterruptedException {
        queue.put(runnable);
    }
    public MyThreadPool1(int n){
        for (int i = 0; i <n ; i++) {
            Thread thread = new Thread(()->{//创建多个线程
                while(true){
                    try {
                        Runnable runnable = queue.take();//创建新的runnable 来获取runnable队列
                        runnable.run();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            });
            thread.start();//循环内 启动新创建的线程
        }
    }


}
public class Demo24 {

}
